<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>新增医师信息</title>
    <%@ include file="/commons/static.jsp"%>
    <link href="${ctx}/dep/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />	
    <link href="${ctx}/dep/moban/css/beyond.min.css" rel="stylesheet" />
    <link href="${ctx}/dep/moban/css/typicons.min.css" rel="stylesheet" />
    <link href="${ctx}/dep/moban/css/animate.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${ctx}/dep/dist/css/dropify.css">
    <link rel="stylesheet" href="${ctx}/dep/zTreeStyle/zTreeStyle.min.css" />
</head>
<body>
           <div class="wrapper">
                <!-- 面包屑导航 -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="index.html">首页</a>
                        </li>
                        <li class="active">
                          <a href="###">医师信息管理</a>
                        </li>
                        <li class="active">
                          医师信息服务
                        </li>
                    </ul>
                </div>
                <!-- /面包屑导航-->
                 <div class="page-body">
                      <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="widget">
                                <div class="widget-body" style="overflow:hidden">
                                	<div class="col-lg-12 col-sm-12 col-xs-12 ">
                                        <div class="widget">
                                            <div class=" bancgud" >
                                            	 <div class="formfont">基础信息</div>

                                            	  <form class="form-horizontal form-bordered searchinfo col-xs-offset-1" method="post" name="doctorForm" id="doctorForm" onsubmit="return validateForm()">
                                                    <div class="form-group">
                                                        <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">医师姓名<span class="help-inline"><font color="red">*</font> </span></label>
                                                        <div class="col-sm-7">
                                                            <input type="text" class="form-control zj-dd"  id="tt" placeholder="  请输入医师姓名" name="name" data-bv-notempty="true" data-bv-notempty-message="医师姓名为必填项，不能为空">
                                                        </div>
                                                    </div>
                                                    <div class="form-group ">
                                                        <label  class="col-sm-2 control-label no-padding-right">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别</label>
                                                        <div class="radio">
                                                            <label >
                                                                <input name="sex" type="radio" checked="checked" value="1">
                                                                <span class="text" checked>男 &nbsp;&nbsp;</span>
                                                            </label>
                                                            <label class="">
                                                                <input name="sex" type="radio" class="" value="2">
                                                                <span class="text">女</span>
                                                            </label>
                                                            <label class="">
                                                                <input name="sex" type="radio" class="" value="0">
                                                                <span class="text">其他</span>
                                                            </label>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label  class="col-sm-2 control-label no-padding-right">手&nbsp;&nbsp;&nbsp;机&nbsp;&nbsp;号<span class="help-inline"><font color="red">*</font> </span></label>
                                                        <div  class="col-sm-7">
                                                            <span class="input-icon icon-right" style="width: 100%">
                                                                <input type="text" class="form-control" placeholder="请输入手机号" name="mobile">
                                                                <i class="glyphicon glyphicon-earphone darkorange"></i>
                                                            </span>
                                                          <!--  <input type="text" class="form-control fl "  >-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right">医师职称</label>
                                                    	<div class="col-sm-7" >
		                                                    <select class="col-sm-12 form-control" name="profession">
		                                                        <option value="1" >住院医师（助教）</option>
                                                                <option value="2" >主治医师（讲师）</option>
                                                                <option value="3" >副主任医师（副教授）</option>
                                                                <option value="4" >主任医师（教授）</option>
		                                                    </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label  class="col-sm-2 control-label no-padding-right">医师职业类别</label>
                                                        <div class="radio">
                                                            <label>
                                                                <input name="type" type="radio" data-bv-field="form-field-radio1" value="1">
                                                                <span class="text" checked="">临床</span>
                                                            </label>
                                                            <label class="">
                                                                <input name="type" type="radio" class="" data-bv-field="form-field-radio1" value="2">
                                                                <span class="text">中医</span>
                                                            </label>
                                                            <label class="">
                                                                <input name="type" type="radio" class="" data-bv-field="form-field-radio1" value="3">
                                                                <span class="text">中西结合</span>
                                                            </label>
                                                            <label>
                                                                <input name="type" type="radio" data-bv-field="form-field-radio1" value="4">
                                                                <span class="text">口腔</span>
                                                            </label>
                                                            <label class="">
                                                                <input name="type" type="radio" class="" data-bv-field="form-field-radio1" value="5">
                                                                <span class="text">公共卫生</span>
                                                            </label>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label  class="col-sm-2 control-label no-padding-right">医师执照<span class="help-inline"></span></label>
                                                        <!-- <div class="col-sm-7">
                                                            <div class="box pull-left mr" >
                                                                <input type="file" class="dropify" data-default-file="" extra="physicianQualificationCertificate"  accept=".gif,.jpg,.jpeg,.png">
                                                            </div>
                                                        </div> -->
                                                        <div class="col-sm-9">
		                                                    <div class="box pull-left mr">
		                                                        <input type="file" class="dropify" extra="creditImg"  data-default-file="">
		                                                    </div>
		                                                    <div class="box pull-left mr">
		                                                        <input type="file" class="dropify" extra="creditImg"  data-default-file="">
		                                                    </div>
		                                                    <div class="box pull-left mr">
		                                                        <input type="file" class="dropify" extra="creditImg"  data-default-file="">
		                                                    </div>
		                                                    <div class="box pull-left mr">
		                                                        <input type="file" class="dropify" extra="creditImg"  data-default-file="">
		                                                    </div>
		                                                    <div class="box pull-left mr">
		                                                        <input type="file" class="dropify" extra="creditImg"  data-default-file="">
		                                                    </div>
		                                                </div>
                                                    </div>
                                                    <input type="hidden" name="physicianQualificationCertificate" style="display: none" id="urlpath">
                                                    <div class="form-group">
                                                        <label  class="col-sm-2 control-label no-padding-right">医师所属科室</label>
                                                        <div  class="col-sm-7">
                                                           <!--  <input type="text" class="form-control fl " name="department" placeholder="请输入科室"> -->
                                                           <div class="input-group">
	                                                            <%-- <input value="${data.departmentId}" type="text" class="form-control" name="department" id="departmentId" style="display: none"> --%>
																<input value="${data.departmentName}"  placeholder="请点击选择按钮" readonly="readonly" type="text" class="form-control" name="department" id="departmentName">
																<span class="input-group-btn">
																	<a href="javascript:selectDepart()" class="btn btn-default" type="button" style="line-height: 20px">选择</a>
																</span>
															</div>
                                                        </div>
                                                    </div>
                                                     <div class="form-group">
                                                        <label  class="col-sm-2 control-label no-padding-right">医师所属单位</label>
                                                        <div  class="col-sm-7">
                                                            <input type="text" class="form-control fl " name="hospital" placeholder="请输入所属单位">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                         <label  class="col-sm-2 col-xs-12 control-label no-padding-right">医院地址</label>
                                                          <div  class="col-sm-2 col-xs-3">
																 <select id="s_province" class="col-lg-12" name="provinces"></select> 
															 </div>
															 <div  class="col-sm-2 col-xs-3">
																 <select id="s_city" class="col-lg-12" name="city"></select> 
															 </div> 
															 <div  class="col-sm-2 col-xs-3">
																 <select id="s_county" class="col-lg-12" name="county"></select>
															 </div>
															  <div  class="col-sm-3 col-xs-12">
																  <input type="text" class="form-control fl "  name="address" placeholder="请输入具体地址"/>
															 </div>
                                                    </div>
                                                    <div class="form-group pad-butom">
                                                        <label  class="col-sm-2 control-label no-padding-right">医师描述</label>
                                                        <div  class="col-sm-7">
                                                             <textarea class="dc_text" name="description"></textarea>
                                                        </div>
                                                    </div> 
                                                </div>
		                                    <div class="row" style="margin-top: 25px">
												<div class="col-lg-6 col-sm-6 col-xs-6  ">
													<div class="form-group hypading">
														<button id="tagIdSubmitAddVip_btn" type="submit" class=" btn btn-darkorange  col-sm-2 col-lg-offset-9 col-xs-offset-8" data-toggle="modal">确认</button>
													</div>
												</div>
												<div class="col-lg-6 col-sm-6 col-xs-6  ">
													<div class="form-group hypading">
														<button class=" btn btn-active col-sm-2" type="button" onClick="history.go(-1)">取消</button>
													</div>
												</div>
												
											</div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                         </div> 
                     </div>       
                  </div>          
                </div>
            </div>
         </div>   
    </div>
            <!-- /右侧内容 -->
</div>
<!--  <div class="modal fade in" id="closeCourse" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content"  style="border-radius:50px!important" >
            
            <div class="modal-body form-horizontal" >
              <p class="text-warning">您的会员信息已提交成功</p>
            </div>
        </div>
    </div>
</div> -->
<div class="modal fade in" aria-hidden="false" id="deparment">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" type="button" data-dismiss="modal">×</button>
						<h4 class="modal-title">选择科室</h4>
					</div>
					<div class="modal-body form-horizontal">
						<form id="searchForm" onsubmit="return submitForm()">
							<div class="form-search">
								<label class="control-label col-lg-4">关键词：</label>
								<input id="keyWord" name="name" type="text" style="width: 200px;display: inline-block;">
								<div style="display: inline-block;margin-left: 10px;">
									<input type="submit" class="btn btn-primary" id="officesearch" value="搜索"/>
								</div>
							</div>
							<div class="area-select" style="margin-top: 20px">
								<ul id="departTree" class="ztree col-lg-offset-4"></ul>
							</div>
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-10 col-sm-offset-2">
									<span class="btn btn-darkorange col-sm-3" id="confirmButton">确定</span>
									<span class="btn btn-active col-sm-3 col-xs-offset-3" id="cancelButton">取消</span>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="modal fade in" aria-hidden="false" id="deparment">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" type="button" data-dismiss="modal">×</button>
						<h4 class="modal-title">选择科室</h4>
					</div>
					<div class="modal-body form-horizontal">
						<form id="searchForm" onsubmit="return submitForm()">
							<div class="form-search">
								<label class="control-label col-lg-4">关键词：</label>
								<input id="keyWord" name="name" type="text" style="width: 200px;display: inline-block;">
								<div style="display: inline-block;margin-left: 10px;">
									<input type="submit" class="btn btn-primary" id="officesearch" value="搜索"/>
								</div>
							</div>
							<div class="area-select" style="margin-top: 20px">
								<ul id="departTree" class="ztree col-lg-offset-4"></ul>
							</div>
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-10 col-sm-offset-2">
									<span class="btn btn-darkorange col-sm-3" id="confirmButton">确定</span>
									<span class="btn btn-active col-sm-3 col-xs-offset-3" id="cancelButton">取消</span>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
    <script src="${ctx}/dep/jquery.selectlist.js"></script>
    <script src="${ctx}/dep/moban/js/validation/bootstrapValidator.js"></script>
    <script type="text/javascript" src="${ctx}/dep/datetime/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="${ctx}/dep/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="${ctx}/dep/fileinput.js" type="text/javascript"></script>
    <script src="${ctx}/dep/fileinput_locale_zh.js" type="text/javascript"></script>
    <script src="${ctx}/dep/dist/js/dropify.js"></script>
    <script src="${ctx}/dep/zTreeStyle/jquery.ztree.all.min.js"></script>
   <script>
    $(function () {
        $('.dropify').dropify({
            messages: {
                'default': '点击或拖拽文件到这里',
                'replace': '点击或拖拽文件到这里来替换文件',
                'remove':  '移除文件',
                'error':   '对不起，你上传的文件太大了'
            }
        });
        $("#doctorForm").bootstrapValidator();
    });
 </script>
 <script>
	   
	    $("#file-1").fileinput({
	        uploadUrl: '#', 
	        allowedFileExtensions : ['jpg', 'png','gif'],
	        overwriteInitial: false,
	        maxFileSize: 100,
	        maxFilesNum: 10,
	       
	        slugCallback: function(filename) {
	            return filename.replace('(', '_').replace(']', '_');
	        }
		});
	     
	     $(function(){
				$('.abcselect').selectlist({
					zIndex: 1000,
					width: 260,
					height: 34
					
				});	
				
				//区域联动
				$.ajax({
					url : ctx + '/manag/area/findArea', //省
					data : {type:2},
					dataType : 'json',
					type : 'post',
					success : function(json){
						
						var data = json.data;
						
						if(json.status == "success"){
							
							var selected = $('#s_province').data('selected');
							
							$('#s_province').html('<option value="0">请选择</option>');
							
							for(var i=0; i<data.length; i++){
								
								if(selected != null &&　selected == data[i].id){
									$('#s_province').append('<option selected="selected" value="'+data[i].id+'">'+data[i].name+'</option>');
									$('#s_province').change();
								}else{
									$('#s_province').append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
								}
							}
						}
					},
					error : function(){
						toastr.error('系统错误');
					}
					
				});
				
				
				$('#s_province').change(function(){
					
					var parentId = $(this).val();
					
					$.ajax({
						url : ctx + '/manag/area/findArea', //市
						data : {type:3,parentId:parentId},
						dataType : 'json',
						type : 'post',
						success : function(json){
							
							var data = json.data
							
							if(json.status == "success"){
								
								var selected = $('#s_city').data('selected');
								
								$('#s_city').html('<option value="0">请选择</option>');
								
								for(var i=0; i<data.length; i++){
									if(selected != null &&　selected == data[i].id){
										$('#s_city').append('<option selected="selected" value="'+data[i].id+'">'+data[i].name+'</option>');
									}else{
										$('#s_city').append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
									}
								}
								$('#s_city').change();
							}
						},
						error : function(){
							toastr.error('系统错误');
						}
						
					});
				})
				
				$('#s_city').change(function(){
					
					var parentId = $(this).val();
					
					$.ajax({
						url : ctx + '/manag/area/findArea', //区县
						data : {type:4,parentId:parentId},
						dataType : 'json',
						type : 'post',
						success : function(json){
							
							var data = json.data;
							
							if(json.status == "success"){
								
								var selected = $('#s_county').data('selected');
								
								$('#s_county').html('<option value="0">请选择</option>');
								
								for(var i=0; i<data.length; i++){
									if(selected != null &&　selected == data[i].id)
										$('#s_county').append('<option selected="selected" value="'+data[i].id+'">'+data[i].name+'</option>');
									else
										$('#s_county').append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
								}
							}
						},
						error : function(){
							toastr.error('系统错误');
						}
						
					});
				})
				
				//图片上传无限添加
				$(document).on('change', 'input.dropify', function() {			
					
					var inputName = $(this).attr('extra');			
					
					var str = '<div class="box pull-left mr"> <input type="file" extra="'+inputName+'" class="dropify" data-default-file="" accept=".gif,.jpg,.jpeg,.png"> </div>';
					
					var count = 0;
				 
					$('input.dropify[extra="'+inputName+'"]').each(function(){
						
						if($(this).parent('div').hasClass('has-preview')){
						
							count++ ;
						}
					
					})
					
					if(count>=4){
					
						$(this).parent().parent().parent().append(str).bind('click', function() {
						  $('.dropify').dropify({
							  messages: {
								  'default': '点击或拖拽文件到这里',
								  'replace': '点击或拖拽文件到这里来替换文件',
								  'remove':  '移除文件',
								  'error':   '对不起，你上传的文件太大了'
							  }
						  });
					    })
					  
					    $('.dropify').dropify({
								messages: {
								'default': '点击或拖拽文件到这里',
								'replace': '点击或拖拽文件到这里来替换文件',
								'remove':  '移除文件',
								'error':   '对不起，你上传的文件太大了'
					       }
						});
					
					}
								
				});
				
				 //文件上传
			    $('input.dropify').change(function(){
			    	
			        var formData = new FormData();  
			        
			        formData.append('uploadfile', $(this)[0].files[0]);
			        
			        var inputName = $(this).attr('extra');
			        	
			        $.ajax({  
			            url: ctx + '/pic/uploadFile' ,  
			            type: 'POST',  
			            data: formData,  
			            async: false,  
			            cache: false,  
			            contentType: false,  
			            processData: false,
			            success: function (data) { 
			            	
			            	if(data.status == "success"){
			            		
			            		var url = $("#urlpath").val();
			            		
			            		if(url != null && url != "")
			            			url += "," + data.path;
			            		else
			            			url = data.path;
			            		$("#urlpath").val(url);
			            		console.info($("#urlpath").val())
			            		
			            	}else{	
			            		toastr.error("上传失败！");
			            	}
			            	
			            },
			            error: function(){
			            	toastr.error("系统错误");
			            }
			    	});
			    });
			})
			function validateForm(){
				$('#doctorForm').data('bootstrapValidator').validate();
				if($('#doctorForm').data('bootstrapValidator').isValid()) {
					$.ajax({
						url : "${ctx}/doctor/save",
						type : "POST",
						data : $("#doctorForm").serialize(),
						dataType : "json",
						success : function(data) {
							if($(data)[0]["code"]=="1"){
								window.location.href = "${ctx}/doctor/index";
							}else{
								toastr.error($(data)[0]["msg"]);
							}
						}
					});
				}
			}
	   //科室表单查询
	     function submitForm(){
	     	//加载科室树
	     	$.ajax({
	     		url : ctx + '/medical/getAllMedicalAndDepartment',
	     		data : $('#searchForm').serialize(),
	     		dataType : 'json',
	     		type : 'post',
	     		success : function(data){
	     			
	     			var zNodes =[];
	     			
	     			if(data.list != null){
	     				
	     				for(var i=0; i<data.list.length; i++){
	     					
	     					var subject = {};
	     					subject['id'] = data.list[i].id;
	     					subject['pId'] = 0;
	     					subject['name'] = data.list[i].institutionsName;
	     					subject['oid'] = data.list[i].id;
	     					
	     					zNodes.push(subject);
	     					
	     					if(data.list[i].depart != null){
	     						
	     						for(var j=0; j<data.list[i].depart.length; j++){
	     							var content = {};
	     							
	     							var id = data.list[i].depart[j].id;
	     							var name = data.list[i].depart[j].name;
	     							
	     							content['id'] = data.list[i].id + '' + id;
	     							content['pId'] = data.list[i].id;
	     							content['name'] = name;
	     							content['oid'] = id;
	     							content['click'] = "selectDepartment("+id+", '"+name+"')";
	     							zNodes.push(content);
	     						}
	     					}
	     				}
	     			}
	     			
	     			var setting = {
	     				check: {
	     					enable: false
	     				},
	     				data: {
	     					simpleData: {
	     						enable: true
	     					}
	     				}
	     			};
	     			
	     			//树加载
	     			$.fn.zTree.init($("#departTree"), setting, zNodes);
	     			var treeObj = $.fn.zTree.getZTreeObj("departTree");
	     			treeObj.expandAll(true);
	     			
	     		},
	     		error : function(){
	     			toastr.error('系统错误');
	     		}
	     	});
	     	
	     	return false;
	     	
	     }


	     function selectDepart(){
	     	
	     	//加载科室树
	     	$.ajax({
	     		url : ctx + '/medical/getAllMedicalAndDepartment',
	     		dataType : 'json',
	     		type : 'post',
	     		success : function(data){
	     			console.info(data)
	     			var zNodes =[];
	     			
	     			if(data.list != null){
	     				
	     				for(var i=0; i<data.list.length; i++){
	     					
	     					var subject = {};
	     					subject['id'] = data.list[i].id;
	     					subject['pId'] = 0;
	     					subject['name'] = data.list[i].institutionsName;
	     					subject['oid'] = data.list[i].id;
	     					
	     					zNodes.push(subject);
	     					
	     					if(data.list[i].depart != null){
	     						
	     						for(var j=0; j<data.list[i].depart.length; j++){
	     							var content = {};
	     							
	     							var id = data.list[i].depart[j].id;
	     							var name = data.list[i].depart[j].name;
	     							
	     							content['id'] = data.list[i].id + '' + id;
	     							content['pId'] = data.list[i].id;
	     							content['name'] = name;
	     							content['oid'] = id;
	     							content['click'] = "selectDepartment("+id+", '"+name+"')";
	     							zNodes.push(content);
	     						}
	     					}
	     				}
	     			}
	     			
	     			var setting = {
	     				check: {
	     					enable: false
	     				},
	     				data: {
	     					simpleData: {
	     						enable: true
	     					}
	     				}
	     			};
	     			
	     			//树加载
	     			$.fn.zTree.init($("#departTree"), setting, zNodes);
	     			var treeObj = $.fn.zTree.getZTreeObj("departTree");
	     			treeObj.expandAll(true);
	     			
	     /*			for(var i=0; i<zznode.length; i++){
	     				
	     				var checkedNode = treeObj.getNodeByParam("id", zznode[i].id, null);
	     				
	     				if(zznode[i].pId != null)
	     					treeObj.checkNode(checkedNode, true, true);
	     			}*/
	     			
	     		},
	     		error : function(){
	     			toastr.error('系统错误');
	     		}
	     	});
	     	
	     	$('#keyWord').val('');
	     	$('#deparment').modal('show');
	     	
	     }

	     function selectDepartment(id, name){
	     	
	     	$('#departmentName').val(name);
	     	/* $('#departmentId').val(id); */
	     	
	     	$('#deparment').modal('hide');
	     }

</script>
   

</body>

</html>
